package set_;

import java.util.HashSet;
import java.util.Objects;

/**
 * @Author 小闽
 * @Date 2024/11/3 20:58
 * @PackageName: set_
 * @ClassName: HashSetIncrement
 * @Description:
 * @Version
 */
@SuppressWarnings({"all"})
public class HashSetIncrement {
    public static void main(String[] args) {
        HashSet hashSet = new HashSet();
        for (int i = 0; i <= 100; i++) {
            hashSet.add(i);
        }
        System.out.println("hashSet=" + hashSet);

        for (int i = 0; i <= 12; i++) {
            hashSet.add(new A(i));
        }

        /*
        当向hashSet增加了一个元素， -> Node -> 加入table，就算是增加了一个
         */
        for (int i = 0; i <= 7; i++) { // 在table的某一条链表上添加了7个对象
            hashSet.add(new A(i));
        }
        for (int i = 0; i <= 7 ; i++) { // 在table的另外一条链表上添加了7个对象
            hashSet.add(new B(i));
        }
    }
}

class A{
    private int n;

    public A(int n) {
        this.n = n;
    }

    @Override
    public int hashCode() {
        return 100;
    }
}
class B{
    private int n;

    public B(int n) {
        this.n = n;
    }

    @Override
    public int hashCode() {
        return 200;
    }
}